package com.ruoyi.develop.goodsReceipt.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.goodsReceipt.mapper.GoodsReceiptMapper;
import com.ruoyi.develop.goodsReceipt.domain.GoodsReceipt;
import com.ruoyi.develop.goodsReceipt.service.IGoodsReceiptService;

import javax.annotation.Resource;

/**
 * 签收单Service业务层处理
 * @author qh
 * @date 2023-01-05
 */
@Service
public class GoodsReceiptServiceImpl implements IGoodsReceiptService {
    @Resource
    private GoodsReceiptMapper goodsReceiptMapper;

    /**
     * 查询签收单
     * @param id 签收单主键
     * @return 签收单
     */
    @Override
    public GoodsReceipt selectById(String id) {
        return goodsReceiptMapper.selectById(id);
    }

    /**
     * 查询签收单列表
     * @param entity 签收单
     * @return 签收单
     */
    @Override
    public List<GoodsReceipt> selectList(GoodsReceipt entity) {
        return goodsReceiptMapper.selectList(entity);
    }

    @Override
    public List<GoodsReceipt> selectListNoScope(GoodsReceipt entity) {
        return goodsReceiptMapper.selectList(entity);
    }

    /**
     * 新增签收单
     * @param entity 签收单
     * @return 结果
     */
    @Override
    public int insert(GoodsReceipt entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return goodsReceiptMapper.insert(entity);
    }

    /**
     * 修改签收单
     * @param entity 签收单
     * @return 结果
     */
    @Override
    public int update(GoodsReceipt entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return goodsReceiptMapper.update(entity);
    }

    /**
     * 批量删除签收单
     * @param ids 需要删除的签收单主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return goodsReceiptMapper.deleteByIds(ids);
    }

    /**
     * 删除签收单信息
     * @param id 签收单主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return goodsReceiptMapper.deleteById(id);
    }
}
